import unittest
import requests


class MyTestCase(unittest.TestCase):
    def test_yiche(self):
        '''易车接口的练习'''
        # 演示URL地址https://selectcar.yiche.com/selectcarforapp?mid=7&s=4&page=1&pagesize=20&cityId=201
        #第一种get的请求方式
        # r=requests.get('https://selectcar.yiche.com/selectcarforapp?mid=7&s=4&page=1&pagesize=20&cityId=201')
        # print(r.json())
        #第二种get的请求方式_params
        tail= {'mid': 7, 's': 4, 'page': 1, 'pagesize': 20, 'cityId': 201}
        r=requests.get('https://selectcar.yiche.com/selectcarforapp',params=tail)
        # print(r.json())
        date=r.json()
        # 这里是对结果进行了断言
        self.assertEqual(date['data']['carNumber'],216)
        #打印json返回值
        # print(r.json())
        #打印url
        # print(r.url)
        #打印文本内容
        # print(r.text)
        #打印编码格式
        # print(r.encoding)
        #打印消息体
        # print(r.content)
        #获取接口状态码
        # print(r.status_code)
        #获取头部信息
        # print(r.headers)
        #获取节点的值
        # print(date['data']['resList'][0]['tags'][2]['value'])

if __name__ == '__main__':
    unittest.main()
